package com.dongss.study.zookeeper;

import java.util.List;

/**
 * Created by dh on 2017/2/27.
 */
public class ListGroup extends ConnectionWatcher {

    public void list(String groupName) throws Exception{
        String path="/"+groupName;
        List<String> children=zk.getChildren(path,false );
        if(children.isEmpty()){
            System.out.printf("No members is group %s",groupName);
            System.exit(1);
        }
        for(String child:children){
            System.out.println(child);
        }
    }

    public static void main(String[] args) throws Exception{
        ListGroup listGroup=new ListGroup();
        listGroup.connect(args[0]);
        listGroup.list(args[1]);
        listGroup.close();
    }
}
